﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Frogism.Core;
using NUnit.Framework;
namespace Frogism.Tests {
  [TestFixture]
  public class DayExtensionTest {
    [Test]
    public void WeekStartDaysAgo() {
      DateTime TestTime = new DateTime(2008, 5, 25); //sunday
      Assert.AreEqual(0, TestTime.WeekStartDaysAgo(),"Sunday");
      Assert.AreEqual(1, TestTime.AddDays(1).WeekStartDaysAgo(), "Monday");
      Assert.AreEqual(2, TestTime.AddDays(2).WeekStartDaysAgo(), "Tuesday");
      Assert.AreEqual(3, TestTime.AddDays(3).WeekStartDaysAgo(), "Wednesday");
      Assert.AreEqual(4, TestTime.AddDays(4).WeekStartDaysAgo(), "Thursday");
      Assert.AreEqual(5, TestTime.AddDays(5).WeekStartDaysAgo(), "Friday");
      Assert.AreEqual(6, TestTime.AddDays(6).WeekStartDaysAgo(), "Saturday");
    }
     [Test]
    public void WeekStartSunday() {
      DateTime TestTime = new DateTime(2008, 5, 25, 0, 0, 0); //sunday
      Assert.AreEqual(TestTime, TestTime.StartOfWeek(), "Sunday");
    }
     [Test]
     public void WeekStartMonday() {
       DateTime TestTime = new DateTime(2008, 5, 26, 1, 0, 0); //monday
       DateTime ExpTime = new DateTime(2008, 5, 25, 0, 0, 0);
      
       Assert.AreEqual(ExpTime, TestTime.StartOfWeek(), "Monday");
      
     }
     [Test]
     public void WeekEnd() {
       DateTime TestTime = new DateTime(2008, 5, 25); //sunday
       DateTime TestEndTime = new DateTime(2008, 5, 25 + 6); //saturday
       Assert.AreEqual(TestEndTime, TestTime.EndOfWeek(), "Sunday");
       Assert.AreEqual(TestEndTime, TestTime.AddDays(1).EndOfWeek(), "Monday");
       Assert.AreEqual(TestEndTime, TestTime.AddDays(2).EndOfWeek(), "Tuesday");
       Assert.AreEqual(TestEndTime, TestTime.AddDays(3).EndOfWeek(), "Wednesday");
       Assert.AreEqual(TestEndTime, TestTime.AddDays(4).EndOfWeek(), "Thursday");
       Assert.AreEqual(TestEndTime, TestTime.AddDays(5).EndOfWeek(), "Friday");
       Assert.AreEqual(TestEndTime, TestTime.AddDays(6).EndOfWeek(), "Saturday");
     }
     [Test]
     public void MonthStart() {
       DateTime TestTime = new DateTime(2008, 5, 25); //sunday
       DateTime TestEndTime = new DateTime(2008, 5, 1); //First of Month
       Assert.AreEqual(TestEndTime, TestTime.StartOfMonth(),"Middle of May");
       Assert.AreEqual(TestEndTime, TestEndTime.StartOfMonth(),"First of May");
     }
     [Test]
     public void MonthEnd() {
       DateTime TestTime = new DateTime(2008, 5, 25); //sunday
       DateTime TestEndTime = new DateTime(2008, 5, 31); //End Of May
       Assert.AreEqual(TestEndTime, TestTime.EndOfMonth(), "Middle of May");
       Assert.AreEqual(TestEndTime, TestEndTime.EndOfMonth(), "End Of May");
     }
     [Test]
     public void YearStart() {
       DateTime TestTime = new DateTime(2008, 5, 25); //sunday
       DateTime TestEndTime = new DateTime(2008, 1, 1); //First of Year
       Assert.AreEqual(TestEndTime, TestTime.StartOfYear(), "Middle of May");
       Assert.AreEqual(TestEndTime, TestEndTime.StartOfYear(), "First of Year");
     }
     [Test]
     public void YearEnd() {
       DateTime TestTime = new DateTime(2008, 5, 25); //sunday
       DateTime TestEndTime = new DateTime(2008, 12, 31); //End Of Year
       Assert.AreEqual(TestEndTime, TestTime.EndOfYear(), "Middle of May");
       Assert.AreEqual(TestEndTime, TestEndTime.EndOfYear(), "End Of Year");
     }
     [Test]
     public void CleanDate() {
       DateTime TestTime = new DateTime(2008, 4, 5, 13, 55, 55);
       DateTime TestResult = new DateTime(2008, 4, 5, 0, 0, 0);
       Assert.AreEqual(TestResult, TestTime.CleanDate());
     }   
  }
}
